package com.xux.controller;

import com.xux.model.po.Teacher;
import com.xux.service.impl.TeacherService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: xux
 * @date: 2022-06-30 15:46
 * @version: 1.0
 **/
@RestController
@RequestMapping("/teacher")
public class TeacherController {

    @Resource
    private TeacherService teacherService;


    @GetMapping("/findAll")
    public List<Teacher> findAll() {
        return teacherService.findAll();
    }

    @GetMapping("/insert")
    public void insert(Teacher teacher) throws Exception {
        teacherService.insert(teacher);
    }

    @GetMapping("/insertBatch")
    public void insertBatch() throws Exception {
        teacherService.insertBatch();
    }

    @GetMapping("find")
    public List<Teacher> getTeacher(@RequestParam Integer age ) {
//        return teacherService.getTeacher(age);

        return teacherService.testPage();
    }

    @GetMapping("/mongoTemplateFind")
    public Teacher mongoTemplateFind(@RequestParam Integer id ) {
        return teacherService.mongoTemplateFind(id);
    }


    @GetMapping("/tt")
    public void test() {
        teacherService.testUpdate();
    }


}
